package com.zjsd.sqeybusiness.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.zjsd.sqeybusiness.domain.CompanyImage;
import com.zjsd.sqeybusiness.service.ICompanyImageService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 企业图片Controller
 *
 * @author Zheng
 * @date 2020-11-05
 */
@RestController
@RequestMapping("/jph/companyImage")
public class CompanyImageController extends BaseController
{
    @Autowired
    private ICompanyImageService companyImageService;

    /**
     * 查询企业图片列表
     */
    @PreAuthorize("@ss.hasPermi('jph:companyImage:list')")
    @GetMapping("/list")
    public TableDataInfo list(CompanyImage companyImage)
    {
        startPage();
        List<CompanyImage> list = companyImageService.selectCompanyImageList(companyImage);
        return getDataTable(list);
    }

    /**
     * 导出企业图片列表
     */
    @PreAuthorize("@ss.hasPermi('jph:companyImage:export')")
    //@Log(title = "企业图片", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(CompanyImage companyImage)
    {
        List<CompanyImage> list = companyImageService.selectCompanyImageList(companyImage);
        ExcelUtil<CompanyImage> util = new ExcelUtil<CompanyImage>(CompanyImage.class);
        return util.exportExcel(list, "companyImage");
    }

    /**
     * 获取企业图片详细信息
     */
    @PreAuthorize("@ss.hasPermi('jph:companyImage:query')")
    @GetMapping(value = "/{imageId}")
    public AjaxResult getInfo(@PathVariable("imageId") Long imageId)
    {
        return AjaxResult.success(companyImageService.selectCompanyImageById(imageId));
    }

    /**
     * 新增企业图片
     */
    @PreAuthorize("@ss.hasPermi('jph:companyImage:add')")
    //@Log(title = "企业图片", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CompanyImage companyImage)
    {
        return toAjax(companyImageService.insertCompanyImage(companyImage));
    }

    /**
     * 修改企业图片
     */
    @PreAuthorize("@ss.hasPermi('jph:companyImage:edit')")
    //@Log(title = "企业图片", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CompanyImage companyImage)
    {
        return toAjax(companyImageService.updateCompanyImage(companyImage));
    }

    /**
     * 删除企业图片
     */
    @PreAuthorize("@ss.hasPermi('jph:companyImage:remove')")
    //@Log(title = "企业图片", businessType = BusinessType.DELETE)
	@DeleteMapping("/{imageIds}")
    public AjaxResult remove(@PathVariable Long[] imageIds)
    {
        return toAjax(companyImageService.deleteCompanyImageByIds(imageIds));
    }
}
